Rails.application.routes.draw do
  # resources :posts

  # root to: 'posts#index'
  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

  # cpanel 新后台管理
  constraints subdomain: 'cpanel' do
    scope module: 'cpanel', as: 'cpanel' do
      root to: 'roots#index'

      resources :roots, only: [:index] do
        get :no_authorized, on: :collection
      end

      resources :qiniu, only: [] do
        get :uptoken, on: :collection
        post :simditor_uploader, on: :collection
      end

      resources :admins do
        patch :reset_password, on: :member
        get :edit_password, on: :collection
        patch :update_password, on: :collection
      end
      resources :products do
        get :modal, on: :collection
      end
      resources :machines do
        get :modal, on: :collection
      end
      resources :grids do
        get :modal, on: :collection
      end
      resources :machine_grids
    end
  end

  devise_for :admins, path: 'admins/auth', controllers: { sessions: 'cpanel/admins/sessions' }
end
